﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DeliveryApproval.aspx.cs" Inherits="Delivery_DeliveryApproval" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>发货审批</title>
    <link href="../CSS/delivery.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/SubStyle.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/jquery-1.4.1-vsdoc.js"></script>
    <script language="javascript" type="text/javascript" src="Jscript/Delivery.js"></script>
    <script type="text/javascript" src="Jscript/popcalendar.js"></script>
    <script language="javascript" type="text/javascript">
        function setWidth() {
            document.getElementById("detailDiv").style.width = document.body.offsetWidth * 0.99;
        }
    </script> 
</head>
<body onload="setWidth();deliveryOnloadApply();">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services><asp:ServiceReference Path="~/webservice/DeliveryApplyWebService.asmx" /></Services>
    </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdHead" runat="server">
          <ContentTemplate>
            <div id="headlocation" class="headlocation" style="text-align:left;">
                <asp:Label ID="Label2" runat="server" Text="<%$ Resources:language, Location %>"></asp:Label>
                <img alt="位置" src="../Image/weizhi.gif" />>>
                <asp:Label ID="Label12" runat="server" Text="审批"></asp:Label>
            </div>
            <div id="covertDiv" class="transp" style="display:none;"></div>
             <div id="creditcheckdiv" class="transp topHeadTable" style="font-size:18px; display:none;">
                 <div style="height:1px; margin:80px 0 10px 0;"></div>
                 <table cellpadding="2" cellspacing="0" class="topHeadTable">                       
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                        </td>
                        <td class="td20">
                        </td>
                        <td class="td15">
                        </td>
                        <td class="td20" style="text-align:right">                            
                            <input class="cmdStyle" type="button" value="返 回"
                            onclick="showOrHidden('creditcheckdiv','none');" />
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr class="trcreditcheck">
                        <td class="td15">
                        </td>
                        <td class="td15 trcreditcheck">
                            DeliveryApplyNo：
                        </td>
                        <td class="td20 trcreditcheck">
                            ************
                        </td>
                        <td class="td15 trcreditcheck">
                            ContractNo.(ITT)：
                        </td>
                        <td class="td20 trcreditcheck">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr class="trcreditcheck">
                        <td class="td15">
                        </td>
                        <td class="td15">
                            客户编号：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            客户名称：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            客户审批未发货总金额：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            订单总金额：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            订单已发货金额：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            订单已匹配金额：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            销售员：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            SO：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            Currency：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            Amount：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            审批日期：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            Remark：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            付款条件：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            付款百分比(%)：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                    <tr>
                        <td class="td15">
                        </td>
                        <td class="td15">
                            信用额度(客户)：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                            信用额度(订单)：
                        </td>
                        <td class="td20">
                            ************
                        </td>
                        <td class="td15">
                        </td>
                    </tr>
                        <tr>
                            <td class="trHeadFoot" colspan="8">
                                
                            </td>
                        </tr>
                 </table>                                     
                 
             </div>
             <fieldset>
                <legend><font style="font-size: 12px">
                    <asp:Label ID="lblLegend1" runat="server" Text="<%$ Resources:language, Legend1 %>"> </asp:Label></font></legend>
                <table cellpadding="0" cellspacing="0" class="topHeadTable">                       
                    <tr>
                        <td colspan="8" class="trHeadFoot">
                        </td>
                    </tr>
                    <tr>
                        <td class="td10">
                        </td>
                        <td class="td10">
                            <asp:Label ID="Label10" runat="server" Text="客户名称:"></asp:Label>
                        </td>
                        <td class="td20">
                            <asp:TextBox ID="txtCustomer" runat="server" CssClass="txtStyleD"></asp:TextBox>
                            <asp:DropDownList ID="ddlCustomer" runat="server" AutoPostBack="true"
                                onblur="showHidden('ddlCustomer','ddlCustomer', 'txtCustomer','imgCustomer')" 
                                CssClass="ddl" onselectedindexchanged="ddlCustomer_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td class="td5left">
                            <img alt="" runat="server" src="../Image/ddl.jpg" id="imgCustomer"
                                onmouseover="showHidden(this.id,'txtCustomer','ddlCustomer','ddlCustomer')" />
                        </td>
                        <td class="td10">
                            <asp:Label ID="Label5" runat="server" Text="销售员:"></asp:Label>
                        </td>
                        <td class="td20">
                            <asp:TextBox ID="txtSaleName" runat="server" CssClass="txtStyleD"></asp:TextBox>
                            <asp:DropDownList ID="ddlSaleName" runat="server" AutoPostBack="true" 
                            onblur="showHidden('ddlSaleName','ddlSaleName', 'txtSaleName', 'imgSaleName')" 
                                CssClass="ddl" onselectedindexchanged="ddlSaleName_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td class="td5left">
                            <img alt="" runat="server" src="../Image/ddl.jpg" id="imgSaleName"
                                onmouseover="showHidden(this.id,'txtSaleName','ddlSaleName','ddlSaleName')" />
                        </td>
                        <td class="td20">
                        </td>
                    </tr>
                    <tr>
                        <td class="td10">
                        </td>
                        <td class="td10">
                            <asp:Label ID="Label7" runat="server" Text="合同号:"></asp:Label>
                        </td>
                        <td class="td20">
                            <asp:TextBox ID="txtContractNo" runat="server" CssClass="txtStyle"></asp:TextBox>
                            <asp:DropDownList ID="ddlContractNo" runat="server" AutoPostBack="true" 
                            onblur="showHidden('ddlContractNo','ddlContractNo', 'txtContractNo','imgContractNo')"
                                CssClass="ddl" onselectedindexchanged="ddlContractNo_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td class="td5left">
                            <img ID="imgContractNo" runat="server" alt="" 
                                onmouseover="showHidden(this.id,'txtContractNo','ddlContractNo','ddlContractNo')" 
                                src="../Image/ddl.jpg" />
                        </td>
                        <td class="td10">
                            <asp:Label ID="Label9" runat="server" Text=" SO#  "></asp:Label>
                        </td>
                        <td class="td20">
                            <asp:TextBox ID="txtSoNo" runat="server" CssClass="txtStyle"></asp:TextBox>
                            <asp:DropDownList ID="ddlSoNo" runat="server" AutoPostBack="true" 
                                onblur="showHidden('ddlSoNo','ddlSoNo', 'txtSoNo', 'imgSoNo')"
                                CssClass="ddl" onselectedindexchanged="ddlSoNo_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td class="td5left">
                            <img ID="imgSoNo" runat="server" alt="" 
                                onmouseover="showHidden(this.id,'txtSoNo','ddlSoNo','ddlSoNo')" 
                                src="../Image/ddl.jpg" />
                        </td>
                        <td class="td20">
                        </td>
                    </tr>           
                        <tr>
                        <td class="td10">
                        </td>
                        <td class="td10">
                            <asp:Label ID="Label86" runat="server" Text="合同号(Customer):"></asp:Label>
                        </td>
                        <td class="td20">
                            <asp:TextBox ID="txtContractNoCustomer" runat="server" CssClass="txtStyle"></asp:TextBox>
                            <asp:DropDownList ID="ddlContractNoCustomer" runat="server" AutoPostBack="true" 
                                CssClass="ddl" 
                                onblur="showHidden('ddlContractNoCustomer','ddlContractNoCustomer', 'txtContractNoCustomer','imgContractNoCustomer')" 
                                ontextchanged="ddlContractNoCustomer_TextChanged">
                            </asp:DropDownList>
                        </td>
                        <td class="td5left">
                            &nbsp;<img ID="imgContractNoCustomer" runat="server" alt="" 
                                onmouseover="showHidden(this.id,'txtContractNoCustomer','ddlContractNoCustomer','ddlContractNoCustomer')" 
                                src="../Image/ddl.jpg" /></td>
                        <td class="td10">
                            <asp:Label ID="Label88" runat="server" Text="状况:"></asp:Label>
                        </td>
                        <td class="td20">
                            <asp:DropDownList ID="ddlState" runat="server" Width="109%" 
                                ontextchanged="ddlState_TextChanged" AutoPostBack="True">
                                <asp:ListItem Value="-1">请选择(Select Please)</asp:ListItem>
                                <asp:ListItem Value="Approval" Selected="True">Waitting for Approval</asp:ListItem>
                                <asp:ListItem Value="Approved">Approved</asp:ListItem>
                                <asp:ListItem Value="Return">Return</asp:ListItem>
                                <asp:ListItem Value="Canceled">Cancel</asp:ListItem>
                                <asp:ListItem Value="Hold">Hold</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="td5left">
                            &nbsp;</td>
                        <td class="td20">
                        </td>
                    </tr>                  
                    <tr style="display:none;">
                        <td class="td10">
                            &nbsp;</td>
                        <td class="td10">
                            <asp:Label ID="Label11" runat="server" Text="<%$ Resources:hwlan, eabd %>"></asp:Label>
                        </td>
                        <td class="td20">
                            <input id="txtDateFrom" runat="server" class="txtStyle" name="date1"
                                                    onclick="popUpCalendar(this,document.forms[0].txtDateFrom,'yyyy-mm-dd')"
                                                    style="width: 100%; cursor: hand"
                                                    type="text" />
                        </td>
                        <td class="td5left">
                            &nbsp;</td>
                        <td class="td10">
                            <asp:Label ID="Label8" runat="server" Text="<%$ Resources:hwlan, eaed %>"></asp:Label>
                        </td>
                        <td class="td20">
                            <input id="txtDateTo" runat="server" class="txtStyle" name="date2" 
                                                onclick="popUpCalendar(this,document.forms[0].txtDateTo,'yyyy-mm-dd')"
                                                    style="width: 100%; cursor: hand" type="text" />
                        </td>
                        <td class="td5left"></td>
                        <td class="td20"></td>
                    </tr>
                    <tr>
                        <td colspan="8" class="trHeadFoot">
                        </td>
                    </tr>
                    </table>                                     
                <div class="cmdButtonsDiv">
                    <asp:Button ID="cmdSearch" runat="server" Text="<%$ Resources:language, CmdSearch %>"
                        CssClass="cmdStyle" OnClick="cmdSearch_Click" />
                    &nbsp;<asp:Button ID="cmdReset" runat="server" CssClass="cmdStyle" OnClick="cmdReset_Click"
                        Text="<%$ Resources:hwlan, reset %>" />&nbsp;
                        <input id="cmdApproval" runat="server" class="cmdStyle" type="button" value="审批通过"
                            onclick="DeliveryApproval(1);" />
                    <input id="cmdHold" class="cmdStyle" type="button" runat="server"  value="保留" 
                            onclick="DeliveryApproval(4);" />
                    <input id="cmdReject" class="cmdStyle" type="button" runat="server"  value="退回"
                        onclick="DeliveryApproval(2)" />
                    <input id="cmdCancel" class="cmdStyle" type="button" runat="server"  value="取消" 
                            onclick="DeliveryApproval(3);" disabled="disabled" />
                </div>
            </fieldset> 
             <script language="javascript" type="text/javascript">
                  function DeliveryApproval(n) {
                      document.getElementById("covertDiv").style.display = "";
                      //alert("");
                      var val = document.getElementById("chkSelectAll");
                      var rowob = document.getElementsByTagName("input");
                      var rowcount = rowob.length;
                      var str = "";

                      for (var i = 1; i < rowcount; i++) {
                          if (rowob[i].checked && rowob[i].id.indexOf("chk") != -1 && rowob[i].name != "contractRow") {
                              str = str + rowob[i].name + "/,";
                          }
                      }
                      if (str.length > 1) {
                          var aa = DeliveryApplyWebService;
                          var userCode = document.getElementById("txtUserCode").value;
                          var coCode = document.getElementById("txtCoCode").value;
                          aa.TradingApproval(n, userCode, coCode, str, abda);
                      }
                  }
                  function abda(str) {
                      if (str > 0) {
                          window.parent.mainFrame.location.href = window.parent.mainFrame.location.href;
                          window.parent.mainFrame.location.reload(); 
                      }
                      document.getElementById("covertDiv").style.display = "none";
                  }
                  function getResult(result) {
                      //$("#divContractNo").append(result[0].toString());
                  }
              </script>
             <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                <ProgressTemplate><span style="font-size:16px; color:Blue;">Data Loading..... </span>             
                </ProgressTemplate>
            </asp:UpdateProgress>   
             <fieldset>
                <legend><span style="font-size: 12px;">
                    <asp:Label ID="lblLegend2" runat="server" Text="列表"></asp:Label></span></legend>
                <div  class="detailDiv" id="detailDiv" style="overflow-y: auto; overflow-x: scroll;">
                    <%= getTrading()%>   
                </div> 
                <input type="text" id="txtForRemark" style="display:none" />
                 <div  style="text-align:left;">
                    <table>
                        <tr>
                            <td>
                                <asp:Label ID="Label85" runat="server" Text="每页显示数据"></asp:Label>
                                <asp:DropDownList ID="ddlPageSize" runat="server" Width="50px" 
                                    AutoPostBack="True" onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
                                    <asp:ListItem>5</asp:ListItem>
                                    <asp:ListItem Selected="True" Value="10"></asp:ListItem>
                                <asp:ListItem Value="15" Text="15"></asp:ListItem>
                                <asp:ListItem Value="20" Text="20"></asp:ListItem>
                                <asp:ListItem Value="25" Text="25"></asp:ListItem>
                                </asp:DropDownList>                                         
                                <asp:Label ID="lblTotal0" runat="server" Text="<%$ Resources:UserSqlPage, Total1 %>"></asp:Label>
                                <asp:Label ID="lblTotal" runat="server"></asp:Label>

                                <asp:Label ID="Total2" runat="server" Text="<%$ Resources:UserSqlPage, Total2 %>"></asp:Label>,
                                <asp:Label ID="Label84" runat="server" Text="<%$ Resources:UserSqlPage, CurrentPage1 %>"></asp:Label>
                                <asp:Label ID="lblPageIndex" runat="server" Text='1'></asp:Label>
                                <asp:Label ID="Label6" runat="server" Text="<%$ Resources:UserSqlPage, CurrentPage2 %>"></asp:Label>,
                                <asp:Label ID="Label3" runat="server" Text="<%$ Resources:UserSqlPage, TotalPage1 %>"></asp:Label>
                                <asp:Label ID="lblPageCount" runat="server" Text='1'></asp:Label>
                                <asp:Label ID="Label4" runat="server" Text="<%$ Resources:UserSqlPage, TotalPage2 %>"></asp:Label>
                                <% //首页/上一页 %>
                                <asp:LinkButton ID="lbtFirstPage" runat="server" Enabled="false" 
                                    Text="<%$ Resources:UserSqlPage, FirstPage %>" onclick="lbtFirstPage_Click" />&nbsp;
                                <asp:LinkButton ID="lbtPreviousPage" runat="server" Enabled="false" 
                                    Text="<%$ Resources:UserSqlPage, PreviousPage %>" 
                                    onclick="lbtPreviousPage_Click" />&nbsp;
                                        
                                <% //下一页/尾页 %>
                                <asp:LinkButton ID="lbtNextPage" runat="server" Enabled="false" 
                                    Text="<%$ Resources:UserSqlPage, NextPage %>" onclick="lbtNextPage_Click" />&nbsp;
                                <asp:LinkButton ID="lbtLastPage" runat="server" Enabled="false" 
                                    Text="<%$ Resources:UserSqlPage, LastPage %>" onclick="lbtLastPage_Click" />                                        
                                <input type="text" id="txtNewPageIndex" runat="server" value="" onblur="checkNumMax(txtIsNumber(this.id))" style="width:25px" />
                                <asp:LinkButton ID="btnGo" runat="server" Text="<%$ Resources:UserSqlPage, PageGo %>" onclick="btnGo_Click"></asp:LinkButton>
                                <script language="javascript" type="text/javascript">
                                    function checkNumMax(flag) {
                                        if (flag) {
                                            var aa = document.getElementById('txtNewPageIndex').value;
                                            var bb = document.getElementById("lblPageCount").innerHTML.toString();
                                            if ((bb < aa)) {
                                                document.getElementById('txtNewPageIndex').value = bb;
                                                window.alert("Not that Page！");
                                            }
                                        }
                                    }
                                    //文本框输入只能为非负数
                                    function txtIsNumber(txtID) {
                                        var a = document.getElementById(txtID).value;
                                        if (!(Math.abs(a) == a) || a == "") {
                                            alert("只能是非负数,也不能为空-Not less than zero！");
                                            document.getElementById(txtID).value = "0";
                                            document.getElementById(txtID).focus();
                                            return false;
                                        }
                                        else
                                        { return true; }
                                    }
                                </script>
                            </td>
                        </tr>
                    </table>
                 </div>    
            </fieldset>
            <asp:HiddenField ID="HidQueryFlag" runat="server" Value="0" />
            <input id="txtUserCode" type="text" runat="server" style="display:none;" />
            <input id="txtCoCode" type="text" runat="server" style="display:none;" />
            <input id="txtCreditBtn" type="text" runat="server" style="display:none;" />            
          </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>

